--
每次买完服务器都是折腾一次,记一下
服务器的系统我一般选的是 unbunt 20.4,并且使用aliyun给的ecs-user帐户
java
amazon-corretto Java 11最新版本
sudo apt update
sudo apt install java-common
wget https://corretto.aws/downloads/latest/amazon-corretto-11-x64-linux-jdk.deb
sudo dpkg -i amazon-corretto-11-x64-linux-jdk.deb
sudo mkdir /var/javaserver/
sudo chown ecs-user /var/javaserver
mkdir -p /var/devopswork/backEnd/bak
sudo chown ecs-user /var/javaserver
nginx
- 安装
sudo apt install nginx-full
- 添加后端转发配置
location ~ /api/ {
proxy_pass http://127.0.0.1:9000;
}
run.sh
- 当时写的时候被bash的语法折腾的够呛
#!/usr/bin/env bash
zero=0
ten=15
pidCount=`ps -ef | grep ludingding-start-0.0.1-SNAPSHOT.jar | grep -v grep |grep -v 'runLudingding.sh'|wc -l`
echo 'pidCount:'$pidCount
if [[ $pidCount -gt $zero ]];
then
echo 'kill ludingding ing'
ps -ef | grep ludingding-start-0.0.1-SNAPSHOT.jar | grep -v grep | awk '{print $2}' | xargs kill
fi
sleepTimes=1
while :
do
sleep 1
echo 'sleepTimes:'$sleepTimes
let "sleepTimes+=1"
pidCount=`ps -ef | grep ludingding-start-0.0.1-SNAPSHOT.jar | grep -v grep |grep -v run.sh|wc -l`
if [[ $pidCount -eq $zero ]];
then
break
fi
if [[ $sleepTimes -gt $ten ]];
then
echo 'kill ludingding force'
ps -ef | grep ludingding-start-0.0.1-SNAPSHOT.jar | grep -v grep | awk '{print $2}' | xargs kill -9
fi
done
echo 'new ludingdign staing'
nohup java -jar /var/javaserver/ludingding-start-0.0.1-SNAPSHOT.jar --mq=true --job=true >>/dev/null 2>&1 &
sleep 10
tail -n 50 /var/javaserver/log/ludingding/app.log